home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / Misc.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  5.1 KB  |  146 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Misc.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.11>    12/13/93    KTA        Changed name of CenterOfScreenClick() to CenterOfRectClick() and
  19. #                                    added support for different types of rects.
  20. #    <1.0.10>     12/2/93    KTA        Updated output
  21. #     <1.0.9>     12/2/93    KTA        Deleted the task DoSpecialTest() it was replaced with hooks.
  22. #                                    Fixed problem where AboutBox() was not reporting any problems if
  23. #                                    window did not appear.
  24. #    <1.0.7+>    11/19/93    NAGA        modify TCS format
  25. #     <1.0.7>     8/25/93    KTA        Added support for parity checking the TCS stack.
  26. #     <1.0.6>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  27. #     <1.0.5>     7/14/93    KTA        International Support: See AboutBox().
  28. #        <1+>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  29. #
  30. # ****************************************************************************
  31. #
  32.  
  33. ########################################################################
  34. #                            External libraries 
  35. #=======================================================================
  36. Libraries "OutPut.Lib","LaunchQuit.Lib","TCS.Lib","UserInterface.Lib", "Geometry.Lib";
  37.  
  38.  
  39. #########################################################################
  40. #                         CenterofRectClick(pSpecifier)
  41. #=======================================================================
  42. # Author:          KTA
  43. # Description:    Clicks in the center of the input parameter <pSpecifier>
  44. # Parameters:    pSpecifier
  45. #                        -1 - indicates the screen
  46. #                        integer <> -1 (or string) is a window specifier
  47. #                        list - should be valid rectangle
  48. # Returns:        Nada
  49. #=======================================================================
  50. # History:
  51. # KTA    12/13/93    Changed the name from CenterofScreenClick and added ability 
  52. #                    to specifiy different types of Rects
  53. #########################################################################
  54. TASK CenterofRectClick(pSpecifier := -1) 
  55. begin
  56.     parameterType := TypeOf(pSpecifier);
  57.     if(parameterType = 'integer') or (parameterType = 'string')
  58.     begin
  59.         if(pSpecifier = -1)
  60.         begin
  61.             Match[screen r:?ScreenRect m:true];
  62.             myPoint := CenterPointOfRect(ScreenRect);
  63.             theDescriptor := 'the screen';
  64.         end;
  65.         else
  66.         begin
  67.             theWind := findWindow(pSpecifier);
  68.             theWindowRect := theWind.r;
  69.             theWindowTitle := theWind.t;
  70.             myPoint := CenterPointOfRect(theWindowRect);
  71.             theDescriptor := "the window titled '{theWindowTitle}'";
  72.         end;
  73.     end;
  74.     if(parameterType = 'list') and (Card(pSpecifier) = 4)
  75.     begin
  76.         myPoint := CenterPointOfRect(pSpecifier);
  77.         theDescriptor := "the rect ({pSpecifier})";
  78.     end;
  79.     
  80.  
  81.     move a:myPoint;
  82.     click;
  83.     LogStr("Moved to the center of {theDescriptor} and clicked");
  84. end; # CenterofRectClick()
  85.  
  86.  
  87. #########################################################################
  88. #                 AboutBox(pDismissAboutBox)
  89. #=======================================================================
  90. # Author:          ML
  91. # Description:    Test the About Box
  92. # Parameters:    pDismissAboutBox -    0    Return key
  93. #                                integer > 0    Click in center of screen {integer} times
  94. #                                {string} select button named {string}
  95. # Returns:        0 - Something failed
  96. #                1 - Successfully selected and dismissed the about box.
  97. #=======================================================================
  98. # History:
  99. # KTA    7/8/93    Changed check for About… menuItem to selectMenuItem(1,1); - intl
  100. # KTA    7/19/93    Changed descriptor so it is not embedded in a list.
  101. # KTA    8/24/93    TCS stack parity check
  102. # KTA    12/01/93    Check to make sure window appears (bug 1121683)
  103. ########################################################################
  104. TASK AboutBox(pDismissAboutBox := 0) 
  105. begin
  106.     tcReturnVal := 0;
  107.     failStr := '';
  108.     #match[menuItem t:?AboutItem o:1 m:[menu o:1]]!;
  109.     theFrontWindow := match[window o:1]!;
  110.     TCSStart({ 1, global kTCSetAboutBox },"Select 'About...'");
  111.     
  112.     returnVal := SelectMenuItem(1,1);
  113.     wait(2);
  114.     AboutBoxWindow:= match[window o:1]!;
  115.     if (theFrontWindow = AboutBoxWindow)
  116.     begin
  117.         tcReturnVal := 0;
  118.         failStr := "!@#$% The 'About Box' did not appear";
  119.         LogStr(failStr);
  120.     end;
  121.     else if (returnVal)
  122.         tcReturnVal := 1;
  123.     
  124.     TCSEnd({ 1, global kTCSetAboutBox },tcReturnVal, failStr);                # Select the 'About…' window
  125.     
  126.     if(tcReturnVal)
  127.     begin
  128.         TCSStart({ 2, global kTCSetAboutBox },"Dismiss About Box");
  129.         if pDismissAboutBox = 0
  130.             SpecialKey(returnKey , "Return Key");
  131.         else if (TypeOf(pDismissAboutBox) = 'string')
  132.             selectButton(pDismissAboutBox);            
  133.         else if TypeOf(pDismissAboutBox) = 'integer'
  134.             for x:= 1 to pDismissAboutBox    
  135.                 CenterofRectClick();
  136.         
  137.         if not FindWindow(AboutBoxWindow)
  138.             tcReturnVal := 1;
  139.         else
  140.             tcReturnVal := 0;
  141.             
  142.         TCSEnd({ 2, global kTCSetAboutBox },tcReturnVal);
  143.     end;
  144.     return(tcReturnVal);
  145. end;
  146.